<div class="chapter_item" id="chapter_{$chapter['id']}" style="background: #fff;">
    <div style="border:1px solid #e7eaec;padding:10px;margin-bottom: 10px;">
        <input name="chapter_id[]" type="hidden" class="form-control chapter_id" value="{$chapter['id']}"/>
        <input name="chapter_status[]" type="hidden" class="form-control chapter_status" value="{$chapter['status']}"/>

        <div class="form-group">
            <div class="col-sm-12">
                <div class="input-group">
                    <span class="input-group-addon">第{$numbers[$chapter['displayorder']]}章</span>
                    <span class="input-group-addon">ID:{$chapter['id']}</span>
                    <span class="input-group-addon">
                        <input type="checkbox" {if $chapter['status']==1}checked{/if} value="1" onclick='statusChapter(this)'>
                        上架
                    </span>
                    <input name="chapter_title[{$chapter['id']}]" type="text" class="form-control chapter_title" value="{$chapter['title']}" placeholder="标题 (比如: 基础课)">
                    <span class="input-group-addon" style="width: 100px;padding: 0;">
                        <input type="text" value="{$chapter['chapters_price']}" class="form-control" placeholder="0.00" readonly>
                    </span>
                    <span class="input-group-addon">
                        元
                    </span>
                    <span class="input-group-addon" style="width: 100px;padding: 0;">
                        <input type="text" value="{$chapter['duration_time']}" class="form-control" placeholder="00:00" readonly>
                    </span>
                    <div class="input-group-btn">
                        <a href="javascript:;" id="add-chapteritem-{$chapter['id']}" chapterid="{$chapter['id']}" class="btn btn-info add-chapteritem" onclick="addChapterItem('{$chapter['id']}')"><i class="icon icon-plus"></i> 添加小节</a>
                        <a href="javascript:void(0);" class="btn btn-danger" onclick="removeChapter('{$chapter['id']}')"><i class="icon icon-remove"></i>删除</a>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label must">封面</label>
            <div class="col-sm-10 col-xs-12 flex">

                <div class="input-group col-sm-6 col-xs-12 img-item">
                    <div class="input-group">
                        <input type="text" name="chapter_thumb[{$chapter['id']}]" value="{$chapter['thumb']}" class="form-control" autocomplete="off">
                        <span class="input-group-btn btn-select-chapter">
                            <button class="btn btn-primary" type="button">选择图片(缩略)</button>
                        </span>
                    </div>
                    <div class="input-group " style="margin-top:.5em;">
                        {if empty($chapter['thumb'])}
                            <img src="/app/admin/static/images/default-pic.jpg" class="img-responsive img-thumbnail" width="150">
                        {else}
                            <img src="{:tomedia($chapter['thumb'])}?x-oss-process=image/resize,h_120,w_200/format,webp" class="img-responsive img-thumbnail" width="150">
                        {/if}
                        <em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除这张图片" onclick="deleteImage(this)">×</em>
                    </div>
                </div>

                <div class="input-group col-sm-5 col-xs-12 img-item" style="margin-left: 30px;display: none;">
                    <div class="input-group">
                        <input type="text" name="thumb_original[{$chapter['id']}]" value="{$chapter['thumb_original']}" class="form-control" autocomplete="off">
                        <span class="input-group-btn btn-select-chapter">
                            <button class="btn btn-primary" type="button">选择图片(原图)</button>
                        </span>
                    </div>
                    <div class="input-group " style="margin-top:.5em;">
                        {if empty($chapter['thumb_original'])}
                            <img src="/app/admin/static/images/default-pic.jpg" class="img-responsive img-thumbnail" width="150">
                        {else}
                            <img src="{:tomedia($chapter['thumb_original'])}" class="img-responsive img-thumbnail" width="150">
                        {/if}
                        <em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除这张图片" onclick="deleteImage(this)">×</em>
                    </div>
                </div>

            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label"></label>
            <div class="col-sm-10 col-xs-12 ">
                <div id="chapter_item_{$chapter['id']}" class="chapter_item_items">

                {foreach $chapter['items'] as $key1 => $chapterItem}
                    {include file='web/goods/index/tpl/chapter_item'}
                {/foreach}

                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg control-label"></label>
            <div class="col-sm-10 col-xs-12 ">
                <div class="input-group">
                    <div class="input-group-btn">
                        <a href="javascript:;" id="add-chapteritem-{$chapter['id']}" chapterid="{$chapter['id']}" class="btn btn-info add-chapteritem" onclick="addChapterItem('{$chapter['id']}')"><i class="icon icon-plus"></i> 添加小节</a>
                        <a href="javascript:void(0);" class="btn btn-danger" onclick="removeChapter('{$chapter['id']}')"><i class="icon icon-remove"></i>删除</a>
                    </div>
                </div>
            </div>
        </div>

    </div> 
</div>

<!--<script>-->
<!--    require(['jquery', 'util'], function ($, util) {-->
<!--        $('.btn-select-chapter').unbind('click').click(function () {-->
<!--            var imgitem = $(this).closest('.img-item');-->
<!--            util.image('', function (data) {-->
<!--                // console.log(data)-->
<!--                imgitem.find('img').attr('src', data['url']);-->
<!--                imgitem.find('input').val(data['attachment']);-->
<!--            });-->
<!--        });-->
<!--    });-->
<!--</script>-->